/**
 * @file export_with_struct.c
 * @author Linquan  
 * @brief 
 * @version 1.0
 * @date 2024-06-06
 * 
 * @copyright Copyright (c) 2024
 * @note 
 *      头文件共分两种export机制，本C文件内容的是export with arg的实现。
 *      头文件中还有 export with constructor 类型，仅通过宏声明或定义完成EXPORT
 */
#include <stdio.h>
#include "export.h"

/************************************************/

#define SECTION_MOD_NUM     6   // 模块初始化优先级数量
#define SECTION_APP_MANGE   7   // 循环调用的等级

extern CMD_LIST SECTION_MOD_START(1);
extern CMD_LIST SECTION_MOD_STOP(1);
extern CMD_LIST SECTION_MOD_START(2);
extern CMD_LIST SECTION_MOD_STOP(2);

extern CMD_LIST SECTION_MOD_START(3);
extern CMD_LIST SECTION_MOD_STOP(3);
extern CMD_LIST SECTION_MOD_START(4);
extern CMD_LIST SECTION_MOD_STOP(4);


extern CMD_LIST SECTION_MOD_START(5);
extern CMD_LIST SECTION_MOD_STOP(5);
extern CMD_LIST SECTION_MOD_START(6);
extern CMD_LIST SECTION_MOD_STOP(6);

extern CMD_LIST SECTION_MOD_START(7);
extern CMD_LIST SECTION_MOD_STOP(7);


CMD_LIST* section_round[] =
{
    &SECTION_MOD_START(1),
    &SECTION_MOD_STOP(1),
    &SECTION_MOD_START(2),
    &SECTION_MOD_STOP(2),
    &SECTION_MOD_START(3),
    &SECTION_MOD_STOP(3),
    &SECTION_MOD_START(4),
    &SECTION_MOD_STOP(4),
    &SECTION_MOD_START(5),
    &SECTION_MOD_STOP(5),
    &SECTION_MOD_START(6),
    &SECTION_MOD_STOP(6),
    &SECTION_MOD_START(7),
    &SECTION_MOD_STOP(7),
};



/************************************************/

/**
 * @brief LV1-6 init
 * 
 */
void export_mode_all_init()
{
    CMD_LIST  *p_func;

    for(int i = 0; i < (2*SECTION_MOD_NUM); i+=2)
    {
        for (p_func = section_round[i]; p_func < section_round[i+1]; p_func++)
        {
            if(p_func->funs)
            {
                 p_func->funs(p_func->cmd);      
            }                 
        }
    }    
}

/**
 * @brief LV7 app cycle
 * 
 */
void export_mode_app_mange()
{
    CMD_LIST  *p_func;

    for (p_func = section_round[((SECTION_APP_MANGE-1)*2)]; \
            p_func < section_round[((SECTION_APP_MANGE*2)-1)]; p_func++)
    {
        if(p_func->funs)
        {
                p_func->funs(p_func->cmd);      
        }                 
    }
}



#ifdef ARMCC_VERSION

#elif __GNUC__
/****************声明 自定义段名*****************************/

static void _level_1_board_export(void* ptr)
{

}
EXPORT_Lv1_BOARD(_level_1_board_export, NULL);


static void _level_2_prev_export(void* ptr)
{

}
EXPORT_Lv2_PREV(_level_2_prev_export, NULL);


void _level_3_device_export(void* ptr)
{
    
}
EXPORT_Lv3_DEVICE(_level_3_device_export, NULL);


void _level_4_component_export(void* a)
{
    
}
EXPORT_Lv4_COMPONENT(_level_4_component_export, NULL);


void _level_5_env_export(void* a)
{

}
EXPORT_Lv5_ENVIRMENT(_level_5_env_export, NULL);


void _level_6_app_init_export(void* str)
{
    
}
EXPORT_Lv6_APP_INIT(_level_6_app_init_export, NULL);


static void _level_7_app_mange_export(void* a)
{
    
}
EXPORT_Lv7_APP_MANGE(_level_7_app_mange_export, NULL);

#endif





